import java.util.Scanner;

/**
 * @Author @fiber-cloud
 * @Date 2025/8/31 20:18
 */

class MyCount{
    //public volatile int flag = 0;

    public int flag = 0;
}
public class ThreadDemo7 {
    public static void main(String[] args) {
        MyCount myCount = new MyCount();

        Thread t1 = new Thread(() -> {
            while (myCount.flag == 0){
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t1 循环结束");
        });


        Thread t2 = new Thread(() -> {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入一个整数");
            myCount.flag = scanner.nextInt();
        });

        t1.start();
        t2.start();
    }
}
